<?php

namespace App\Http\Validate\Custom;

use App\Http\Validate\BaseValidate;

/**
 * 客户信息验证器
 */
class Custom extends BaseValidate
{
    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'code' => 'required',
                'company_code' => 'required',
                'company_name' => 'required',
                'category' => 'required',
                'settlement_company' => 'required',
                'wechat_number' => 'required',
//                'account_name' => 'required',
                'bank_info' => 'required',
                'payment_info' => 'required',
                // 'invoice_info'=>'required',
            ];
            $this->message = [
                'code.required' => '编码不能为空',
                'company_code.required' => '往来单位编码不能为空',
                'company_name.required' => '往来单位名称不能为空',
                'category.required' => '性质不能为空',
                'settlement_company.required' => '结算公司不能为空',
                'wechat_number.required' => '微信号不能为空',
//                'account_name.required' => '户名不能为空',
                'bank_info.required' => '银行信息不能为空',
                'payment_info.required' => '办款信息不能为空',
                // 'invoice_info.required' => '开票信息不能为空',

            ];
        } elseif ($doaction == 'edit') {
            $this->rule = [
                'id' => 'required',
                'company_name' => 'required',
                'settlement_company' => 'required',
                'wechat_number' => 'required',
//                'account_name' => 'required',
                'bank_info' => 'required',
                'payment_info' => 'required',
            ];
            $this->message = [
                'id.required' => '客户信息不能为空',
                'company_name.required' => '往来单位名称不能为空',
                'settlement_company.required' => '结算公司不能为空',
                'wechat_number.required' => '微信号不能为空',
//                'account_name.required' => '户名不能为空',
                'bank_info.required' => '银行信息不能为空',
                'payment_info.required' => '办款信息不能为空',
            ];
        } elseif ($doaction == 'handlecustomreview') {
            $this->rule = [
                'id' => 'required',
                'custom_status' => 'required|in:1,2,3,4',
            ];
            $this->message = [
                'id.required' => '客户信息不能为空',
                'custom_status.required' => '客户审核状态不能为空',
                'custom_status.in' => '参数非法',
            ];
        } elseif ($doaction == 'handleinvoicereview') {
            $this->rule = [
                'id' => 'required',
                'invoice_status' => 'required|in:1,2,3,4',
            ];
            $this->message = [
                'id.required' => '客户信息不能为空',
                'invoice_status.required' => '客户审核状态不能为空',
                'invoice_status.in' => '参数非法',
            ];
        }
    }
}
